package com.sgb.kjwl.view.ui.adapter.self;

import android.content.Context;
import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.ProCarInfoEntity;

import java.util.List;

/**
 * Describe:
 * Author:  yangLei
 * Date:    2021/10/13
 */
public class ProCarListAdapter extends BaseQuickAdapter<ProCarInfoEntity, BaseViewHolder> {

    private Context mContext;

    public ProCarListAdapter(Context context, @Nullable List<ProCarInfoEntity> data) {
        super(R.layout.app_proprietary_car_list_item, data);
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, ProCarInfoEntity item) {
        helper.setText(R.id.car_number, !TextUtils.isEmpty(item.getCarNumber()) ? item.getCarNumber() : "")
                .setText(R.id.car_info, item.getCarInfo());
        RoundedImageView imageView = helper.getView(R.id.car_img);
        if (!TextUtils.isEmpty(item.getImgUrl())) {
            Glide.with(mContext)
                    .load(item.getImgUrl())
                    .placeholder(R.mipmap.ic_car_manager_default)
                    .error(R.mipmap.ic_car_manager_default)
                    .into(imageView);
        }
    }
}
